package com.IM.result;

import com.alibaba.fastjson.JSON;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    private String name;
    private String message;
    private LocalDateTime localDateTime;

    public static TextWebSocketFrame success(String username,String message){
        return new TextWebSocketFrame(JSON.toJSONString(new Result(username,message,LocalDateTime.now())));
    }
    public static TextWebSocketFrame success(String message){
        return new TextWebSocketFrame(JSON.toJSONString(new Result("系统消息",message,LocalDateTime.now())));
    }
    public static TextWebSocketFrame fail(String message){
        return new TextWebSocketFrame(JSON.toJSONString(new Result("系统消息",message,LocalDateTime.now())));
    }

}
